Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

165
Visualizações
behaviourSubject returns [object][object] when its subscribed

Im working with a bank API for the payment.what banks want to response is he Ban Pay JavaScript will perform an HTTP redirect in the top frame to the completeUrl. what completeUrl the url i should give the bank api to send their response.in my app.component.ts

          this.http.post("BankEndURL",quote,).subscribe(s=>{
    //here i get quote 
      this.newpay=s;
      
      //here im passing the paymentID to my service in angular to store there,because 
            at the end of the transaction ,if its successful i need it to show the transaction data
            this.dataService.setData(s);
       //here i send a quote to backend to give me a bankurl with payment data
       this.http.post("SecondBakednURL",this.newpay).subscribe(s=>{
     
         this.payaddress= s['reDirectAuthorizationHref'];
         //here i open the url to redirect the user to the payment portal
          window.open(this.payaddress);

here is the service i have created :

public sharedData = new BehaviorSubject<any>(null);

constructor() {}

  getData(){   
  return this.sharedData;
       }

setData(data:any){
this.sharedData.next(data);
}

and here is my receiver component,the one which the bank will hit it once the transaction is successful,im going to show the transction data of the user

        constructor(private dataService:DataService) {}

      ngOnInit(): void {
        this.dataService.getData().pipe(
          filter(data => !!data)
        ).subscribe(data => {
          alert(data)
        });

but data here returns null

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In this case, getSharedData() returns the behavior subject itself, so the sensible thing to do in this case is to subscribe to it in order to receive the data that you are emitting when calling setData.

In the receiver component:

ngOnInit(): void {
  this.dataService.getData().pipe(
    filter(data => !!data)
  ).subscribe(data => {
    alert(data)
  });
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda